home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / UNIX / Strip Fonts.shar < prev    next >
Internet Message Format  |  1992-08-29  |  42KB

  1. Date: Fri, 15 May 92 02:08 CDT 
  2. From: Dominik Hoffmann <HOFFMANN@macc.wisc.edu>
  3. Subject: StripFonts-unix.shar 
  4.  
  5. This is the Unix side of the StripFonts utility to be found in the info-mac/util
  6. directory. It had been removed from the archive. It should probably go into the
  7. info-mac/unix directory.
  8.  
  9. Thanks a lot
  10.  
  11. Dominik Hoffmann (I am not the author.)
  12.  
  13. --------------------------------------------------------------------------------
  14.  
  15. [This is essentially the same text as found in the "Readme" file in
  16.  the StripFonts.hqx archive.]
  17.  
  18. What is StripFonts?
  19. ------------------
  20.  
  21. StripFonts is a program designed to be useful to a very specific set
  22. of people: those who frequently print documents by creating a
  23. PostScript file on the Mac, transferring that file to a UNIX machine,
  24. and sending it to a PostScript-compatible printer which is networked
  25. to the UNIX machine. In particular, it is aimed at people who use
  26. Adobe Type Manger, or who frequently use non-standard PostScript
  27. typefaces; in other words, people who have PostScript outline fonts in
  28. their system folders. It is also helpful to people using System 7, who
  29. no longer have the option of omitting the Apple ProcSet from their
  30. PostScript files.
  31.  
  32. The presence of outline fonts in the system folder causes the printer
  33. driver to include a copy of the PostScript font definition of each
  34. font used in the document. This is because there is no way for the
  35. printer driver to know in advance which fonts will be available on the
  36. particular printer that you end up using (different printers have
  37. different sets of fonts built in, or on disk). When the printer is
  38. connected to the Macintosh itself, this is not a problem, since the
  39. Mac can ask the printer at the time of printing. However, this
  40. interaction is not possible when the printing will be performed at a
  41. later time from a different machine.
  42.  
  43. The font descriptions can increase the size of the PostScript file to
  44. a startling degree, making the file-transfer process quite unwieldy.
  45. This is where StripFonts comes into play. The StripFonts package
  46. allows you remove the font definitions from a PostScript file before
  47. sending it to the UNIX machine. It can learn which fonts are built in
  48. to the printer that you will be using, and remove them "permanently"
  49. from the file, which will speed up printing time as well. StripFonts
  50. will also let you keep copies of non-built-in typefaces in a directory
  51. under UNIX, and omit those font definitions during the transfer
  52. between the Mac and the UNIX machine, saving greatly on transfer time.
  53. They need to be re-inserted into the file before it can be printed, or
  54. the printer will not be able to use the typefaces; the UNIX side of
  55. StripFonts does this. A similar trick can be used to temporarily
  56. remove the ProcSet which teaches the printer the "shorthand" that the
  57. Mac's LaserWriter driver uses.
  58.  
  59. The current version of StripFonts can tell the difference between
  60. PostScript and TrueType fonts, and has no problem keeping both
  61. versions of a font, even if they have the same name. It also has an
  62. "others" category for font types that it does not recognize; for
  63. example, Macintosh bitmap fonts for which no outlines exist.
  64.  
  65. In my experience with using StripFonts, the time saved in uploading is
  66. considerable. Typical documents (before stripping) for me are about
  67. 600K; after stripping they are cut down to about 40K. After adding the
  68. support for multiple font types and ProcSet removal, I created a test
  69. document using an Adobe PostScript font and a bitmap font. It was 300K
  70. bytes long. Stripping out the fonts and the ProcSet cut it down to 2K!
  71. The UNIX end reconstituted and printed it just fine.
  72.  
  73. Note that if you use TrueType fonts in a document the TrueType
  74. rendering engine needs to be included so that the PostScript printer
  75. knows how to deal with the fonts. This is pretty big, on the order of
  76. 100K all by itself. I don't see any easy way for StripFonts to remove
  77. it, either, since there are no comments bracketing it to identify it
  78. or provide a version number. I can't really trust the code itself to
  79. remain static enough to blindly edit it out. Apple, you could help us
  80. out here by making this code easier to locate.
  81.  
  82.  
  83. Instructions
  84. -----------
  85.  
  86. StripFonts comes in two parts, a Macintosh side, for which I supply a
  87. standalone application, and a UNIX side, which is presently
  88. implemented in C-shell scripts and Emacs LISP, to be interpreted by
  89. the Free Software Foundation's GNU-Emacs editor. (Yes, I'm a little
  90. schizophrenic to like both Macs and the F.S.F. but what can you do?)
  91. If you don't have access to GNU-Emacs and don't want to try finding
  92. and installing it, you could try lighting a fire under me (or someone
  93. else) to write a more portable C version of the Unix side of
  94. StripFonts. I will likely do it very soon if nobody else does, but
  95. please let me know if you write one, so that I can include it in
  96. future distributions!
  97.  
  98. The Mac application is called "StripFonts" and should be prominently
  99. present in this archive. Directions on how to use it are in the file
  100. "Mac help" until I manage to track down (or write) a nice
  101. public-domain help interface which uses the Think Class Library, and
  102. get a version of Think C that supports Balloon Help.
  103.  
  104. The UNIX portions are in a shar archive that was posted separately;
  105. this archive has its own Readme file.
  106.  
  107.  
  108. Distribution
  109. -----------
  110.  
  111. StripFonts is free, and is distributed under John Rotenstein's
  112. wonderful HappiWare licensing scheme: If you like it, remember to
  113. smile! I would appreciate feedback about who is using the program,
  114. stating what you like, and what you would like to see, but I can
  115. obviously not promise to implement every suggested improvement since
  116. I'm supposed to be working on my degree instead of this kind of
  117. project.
  118.  
  119. If you really find the program useful, please send me a picture
  120. postcard of your home town. If you're rich and want to help foster
  121. future development by this impoverished student I wouldn't turn down
  122. money either, but it should be clear that you are not expected (let
  123. alone obligated) to pay for using this program.
  124.  
  125. Although it is free, it is not in the public domain in the following
  126. sense: I retain the copyright on the package and set the terms under
  127. which distribution may occur. Those terms are: You may freely
  128. distribute copies of StripFonts as long as you do so in unmodified
  129. form, and include all files and documentation which are present in
  130. this archive. You may not charge for copies of StripFonts. User groups
  131. and similar organizations may include StripFonts on disks of collected
  132. software, as long as they do not charge more than $10 for the disks.
  133. Bulletin boards, archives and anonymous FTP sites may freely offer
  134. StripFonts. Portions of the code are Copyright (C) 1989 Symantec
  135. Corporation; this does not adversely affect the above-outlined
  136. distribution terms because of the reasonable nature of their licensing
  137. agreement.
  138.  
  139. I can be reached as elliott@cs.wisc.edu or,
  140.  
  141.     James Elliott
  142.     746 W. Main St. #302
  143.     Madison, WI 53715
  144.  
  145.  
  146. Trademarks.
  147. -----------
  148. UNIX is a trademark of AT&T Bell Laboratories. PostScript and Adobe
  149. Type Manager are trademarks of Adobe Systems, Inc.
  150.  
  151. -------------cut here-----------------------------------------------------------
  152. #!/bin/sh
  153. # This is a shell archive (shar 3.21)
  154. # made 08/08/1991 22:55 UTC by elliott@veronica
  155. # Source directory /var/home/elliott/stripfonts
  156. #
  157. # existing files WILL be overwritten
  158. #
  159. # This shar contains:
  160. # length  mode       name
  161. # ------ ---------- ------------------------------------------
  162. #   4961 -rw-r--r-- Readme
  163. #   1774 -rwxr-xr-x list-fonts
  164. #   5149 -rwxr-xr-x print
  165. #   2609 -rwxr-xr-x strip-fonts
  166. #   2649 -rwxr-xr-x strip-procsets
  167. #  13838 -rw-r--r-- stripfonts.el
  168. #
  169. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  170.  then TOUCH=touch
  171.  else TOUCH=true
  172. fi
  173. # ============= Readme ==============
  174. echo "x - extracting Readme (Text)"
  175. sed 's/^X//' << 'SHAR_EOF' > Readme &&
  176. XFor More Information
  177. X--------------------
  178. X
  179. XThe documentation describing what StripFonts does and who will find it
  180. Xuseful is contained in a Macintosh TeachText document titled "Read Me",
  181. Xand is part of the BinHexed Stuffit archive that contains the Macintosh
  182. Xside of the package. Download and extract that archive and read the
  183. Xfile if you are mystified about the purpose of this code.
  184. X
  185. X
  186. XInstallation
  187. X------------
  188. X
  189. XThe UNIX end of StripFonts consists of a set of functions written in
  190. XGNU Emacs LISP (stripfonts.el), and a set of C-shell scripts to allow
  191. Xconvenient access to those functions (print, list-fonts, strip-fonts
  192. Xand strip-procsets).
  193. X
  194. XYou will probably only need to use the "print" and "list-fonts"
  195. Xscripts; the other two are basically examples of how to call
  196. Xindividual functions from the shell. For more details on the scripts
  197. Xand functions themselves, read the comments in the files. Naturally,
  198. Xyou can call the functions directly from within emacs if you have
  199. Xloaded the stripfonts.el library. For myself, I have "autoload"
  200. Xdirectives for the library in my .emacs, so that if I try and call the
  201. Xmajor functions without previously loading the library, it will
  202. Xautomagically be loaded.
  203. X
  204. XYou will want to put the scripts somewhere that is part of the shell
  205. Xsearch-paths of the people who will be using them, and put
  206. Xstripfonts.el somewhere that will be accessible to everyone since the
  207. Xscripts need to be able to read it.
  208. X
  209. X
  210. XConfiguration
  211. X-------------
  212. X
  213. XThen you will need to edit the configuration section of each of the
  214. Xscripts at least enough to set the value of the variable that tells
  215. Xthe script where stripfonts.el can be found.
  216. X
  217. XYou will also need to edit the configuration variables in
  218. Xstripfonts.el to determine where the font and ProcSet archives should
  219. Xgo. Again, this should be somewhere accessible to all users of the
  220. Xpackage.
  221. X
  222. XOnce you have done this, you should create those directories.  You can
  223. Xhave stripfonts.el do that for you: Run Emacs, load the stripfonts
  224. Xlibrary (M-x load-file stripfonts.el), then execute the command
  225. Xsetup-directories (M-x setup-directories). Make sure you've configured
  226. Xthe variables properly first!
  227. X
  228. XFor faster performance, you might want to have emacs byte-compile the
  229. Xstripfonts.el library, and then have the scripts load stripfonts.elc
  230. Xinstead.
  231. X
  232. X
  233. XEveryday use
  234. X------------
  235. X
  236. XCreate a PostScript document on the Mac. Run StripFonts on it there.
  237. XUpload the stripped version to UNIX. Use the "print" script to print
  238. Xit out. This will automatically save copies of any new PostScript
  239. Xfonts and ProcSets that were found in the document into the local
  240. XStripFonts archive, and keep the minimal-sized version of the
  241. Xdocument.
  242. X
  243. XWhenever you get new fonts or ProcSets this way, use the "list-fonts"
  244. Xscript to generate an up-to-date list of the available fonts and
  245. XProcSets, download this to the Mac and use it to update the Mac's
  246. Xnotion of what fonts and ProcSets to remove for the uploading phase.
  247. X
  248. XIf you are using System 7.0, the PostScript output from the mac should
  249. Xbe printable "as-is". If you are using an earlier version of the
  250. Xsystem, you probably already know that the PostScript needs to be
  251. Xchanged a little bit to work, and you will be using a package called
  252. X"macps" to do this for you. You may continue to use macps in addition
  253. Xto StripFonts; in fact, the "print" script will automatically feed its
  254. Xoutput through macps if you give it the "-m" option when running it,
  255. Xor edit its configuration variables such that this is the default.
  256. X
  257. X
  258. XCopying
  259. X-------
  260. X
  261. XStripFonts is free, and is distributed under John Rotenstein's
  262. Xwonderful HappiWare licensing scheme: If you like it, remember to
  263. Xsmile! I would appreciate feedback about who is using the program,
  264. Xstating what you like, and what you would like to see, but I can
  265. Xobviously not promise to implement every suggested improvement since
  266. XI'm supposed to be working on my degree instead of this kind of
  267. Xproject.
  268. X
  269. XIf you really find the program useful, please send me a picture
  270. Xpostcard of your home town. If you're rich and want to help foster
  271. Xfuture development by this impoverished student I wouldn't turn down
  272. Xmoney either, but it should be clear that you are not expected (let
  273. Xalone obligated) to pay for using this program.
  274. X
  275. XAlthough it is free, it is not in the public domain in the following
  276. Xsense: I retain the copyright on the package and set the terms under
  277. Xwhich distribution may occur. Those terms are: You may freely
  278. Xdistribute copies of StripFonts as long as you do so in unmodified
  279. Xform, and include all files and documentation which are present in
  280. Xthis archive. You may not charge for copies of StripFonts.  User
  281. Xgroups and similar organizations may include StripFonts on disks of
  282. Xcollected software, as long as they do not charge more than $10 for
  283. Xthe disks.  Bulletin boards, archives and anonymous FTP sites may
  284. Xfreely offer StripFonts.
  285. X
  286. XI can be reached as elliott@cs.wisc.edu or,
  287. X
  288. X    James Elliott
  289. X    746 W. Main St. #302
  290. X    Madison, WI 53715
  291. SHAR_EOF
  292. $TOUCH -am 0614202591 Readme &&
  293. chmod 0644 Readme ||
  294. echo "restore of Readme failed"
  295. set `wc -c Readme`;Wc_c=$1
  296. if test "$Wc_c" != "4961"; then
  297.     echo original size 4961, current size $Wc_c
  298. fi
  299. # ============= list-fonts ==============
  300. echo "x - extracting list-fonts (Text)"
  301. sed 's/^X//' << 'SHAR_EOF' > list-fonts &&
  302. X#!/bin/csh -f
  303. X# list-fonts, shell-level command for generating a list of the fonts
  304. X#       which have been uploaded so far.
  305. X#
  306. X#       This is part of the StripFonts package, (C) 1991 James Elliott
  307. X#       (elliott@cs.wisc.edu).  See the global "Readme" file for
  308. X#       copying information. Requires the GNU Emacs LISP file
  309. X#       stripfonts.el in order to run (and thus, GNU Emacs as well).
  310. X#
  311. X# Use: This script should be run whenever you have added new fonts to
  312. X#       your UNIX stripfonts configuration (for example, by using the
  313. X#       "print" script to print a document that contained fonts that
  314. X#       were not previously uploaded). This script will create a file
  315. X#       called "StripTargets" which should be downloaded to the
  316. X#       Macintosh end of StripFonts, and opened within StripFonts
  317. X#       there, and saved as the default font list (see the Macintosh
  318. X#       documentation for more details if you need them).
  319. X#
  320. X#       This will allow the Macintosh end of StripFonts to know
  321. X#       exactly what fonts you have available, compacting future
  322. X#       PostScript docments even more.
  323. X#
  324. X# Configuration: STRIPFONTS_DIR should be set to the name of the
  325. X#       directory which contains stripfonts.el. TMP_DIR should be
  326. X#       set to the name of a directory for temporary files; its
  327. X#       default setting is probably fine.
  328. X
  329. X# Find out what directories to use.
  330. Xif (! $?STRIPFONTS_DIR) then
  331. X    set STRIPFONTS_DIR = "/var/elisp"
  332. Xendif
  333. Xif (! $?TMP_DIR) then
  334. X    set TMP_DIR = "/tmp"
  335. Xendif
  336. X
  337. X# Create a file telling emacs what to do.
  338. Xset ctrl_file = "$TMP_DIR/sfec.$$"
  339. Xecho '(load "'$STRIPFONTS_DIR'/stripfonts")' >$ctrl_file
  340. Xecho '(list-fonts "StripTargets")' >>$ctrl_file
  341. X
  342. X# Fire up Emacs to do the real work.
  343. Xemacs -batch -l $ctrl_file
  344. X/bin/rm -f $ctrl_file
  345. SHAR_EOF
  346. $TOUCH -am 0725171191 list-fonts &&
  347. chmod 0755 list-fonts ||
  348. echo "restore of list-fonts failed"
  349. set `wc -c list-fonts`;Wc_c=$1
  350. if test "$Wc_c" != "1774"; then
  351.     echo original size 1774, current size $Wc_c
  352. fi
  353. # ============= print ==============
  354. echo "x - extracting print (Text)"
  355. sed 's/^X//' << 'SHAR_EOF' > print &&
  356. X#!/bin/csh -f
  357. X# print, shell-level command for printing a Macintosh PostScript document
  358. X#       from which fonts and/or ProcSets have been stripped.
  359. X#
  360. X#       This is part of the StripFonts package, (C) 1991 James Elliott
  361. X#       (elliott@cs.wisc.edu).  See the global "Readme" file for
  362. X#       copying information. Requires the GNU Emacs LISP file
  363. X#       stripfonts.el in order to run (and thus, GNU Emacs as well).
  364. X#
  365. X# Use: This script should be run whenever you have a partially or
  366. X#       fully stripped document that you want to print. The default
  367. X#       behavior of this script is to strip any new fonts and ProcSets
  368. X#       from the document (so that they become available in the
  369. X#       archive and need not be uploaded from now on), then save the
  370. X#       stripped version (so that it takes less space), then create a
  371. X#       temporary file which includes all the fonts and ProcSets,
  372. X#       sending it to the printer.
  373. X#
  374. X#       This default can be changed by supplying command-line
  375. X#       arguments, or editing the configuration variables as described
  376. X#       below. For example, you may wish to pipe the document through
  377. X#       macps (if the document was not created by the System 7 version
  378. X#       of the LaserWriter driver), or just write it to standard out
  379. X#       so that it can be part of a pipeline.
  380. X#
  381. X# Configuration: STRIPFONTS_DIR should be set to the name of the
  382. X#       directory which contains stripfonts.el. TMP_DIR should be
  383. X#       set to the name of a directory for temporary files which
  384. X#       will have enough room to hold the big PostScript files to
  385. X#       go to the printer.
  386. X#
  387. X#       If you want the default behavior to be NOT to save the
  388. X#       stripped version of the file, change the line "set strip=1"
  389. X#       immediately below to read "set strip=0".  Then, unless you
  390. X#       specify the "-s" option, stripped versions of documents will
  391. X#       not be saved. Note that new fonts and ProcSets will not be
  392. X#       automatically added to the archives either.
  393. X#
  394. X#       If you want to send output through macps by default, change
  395. X#       the line "set use_macps=0" to "set use_macps=1". Then, unless
  396. X#       you specify the "+m" option, macps will be used.
  397. X
  398. X# Get the base name of this shell script. Have to do it this way
  399. X# because a bug in tcsh prevents $0:t from working.
  400. Xset progname=$0
  401. Xset progname=$progname:t
  402. X
  403. X# Find out where the directories are supposed to be
  404. Xif (! $?STRIPFONTS_DIR) then
  405. X    set STRIPFONTS_DIR = "/var/elisp"
  406. Xendif
  407. Xif (! $?TMP_DIR) then
  408. X    set TMP_DIR = "/tmp"
  409. Xendif
  410. X
  411. X# Set up default behavior.
  412. Xset strip=1
  413. Xset use_macps=0
  414. Xset strip_aldus=0
  415. Xset printer=""
  416. Xset files=""
  417. Xset filter=0
  418. X
  419. X# Parse command-line arguments.
  420. Xtop:
  421. Xif ($#argv > 0) then
  422. X    switch ($1:q)
  423. X
  424. X    case -P*:
  425. X    set printer = "$1:q"
  426. X    shift
  427. X    goto top
  428. X
  429. X    case -t:
  430. X    set filter = 1
  431. X    shift
  432. X    goto top    
  433. X
  434. X    case -s:
  435. X    set strip = 1
  436. X    shift
  437. X    goto top
  438. X
  439. X    case -m
  440. X    set use_macps = 1
  441. X    shift
  442. X    goto top
  443. X
  444. X    case -a
  445. X    set strip_aldus = 1
  446. X    shift
  447. X    goto top
  448. X
  449. X    case -*:
  450. X    echo "$progname"": unknown option, $1:q"
  451. X    goto usage
  452. X
  453. X    case +t:
  454. X    set filter = 0
  455. X    shift
  456. X    goto top    
  457. X
  458. X    case +s:
  459. X    set strip = 0
  460. X    shift
  461. X    goto top
  462. X
  463. X    case +m:
  464. X    set use_macps = 0
  465. X    shift
  466. X    goto top
  467. X
  468. X    case +a
  469. X    set strip_aldus = 0
  470. X    shift
  471. X    goto top
  472. X
  473. X    case +*:
  474. X    echo "$progname"": unknown option, $1:q"
  475. X    goto usage
  476. X
  477. X    default:
  478. X    set files = "$files $1:q"
  479. X    shift
  480. X    goto top
  481. X    endsw
  482. Xendif
  483. X
  484. X# If nothing to process, complain.
  485. Xif ("$files" == "") goto usage
  486. X
  487. X# Create a file telling emacs what to do
  488. Xset ctrl_file = "$TMP_DIR/sfec.$$"
  489. Xecho '(load "'$STRIPFONTS_DIR'/stripfonts")' >$ctrl_file
  490. X
  491. X# Add commands to strip the new fonts, if appropriate
  492. Xif ($strip != 0) then
  493. X    echo "(strip-fonts)" >>$ctrl_file
  494. X    echo "(strip-procsets)" >>$ctrl_file
  495. X    echo "(save-buffer)" >>$ctrl_file
  496. Xendif
  497. X
  498. X# Similarly for stripping the Aldus error handler
  499. Xif ($strip_aldus != 0) then
  500. X    echo "(strip-aldus-error-handler)" >>$ctrl_file
  501. Xendif
  502. X
  503. X# Now a command to include the fonts for printing
  504. Xecho "(include-fonts)" >>$ctrl_file
  505. Xecho "(include-procsets)" >>$ctrl_file
  506. X
  507. X# And finally, pick a file for emacs to write the temporary results to
  508. Xset dest_file = "$TMP_DIR/ps.$$"
  509. Xecho '(write-file "'$dest_file'")' >>$ctrl_file
  510. X
  511. X# Now process each of the files
  512. Xforeach i ($files)
  513. X    if ($filter == 0) then
  514. X    emacs -batch $i -l $ctrl_file
  515. X    if ($use_macps != 0) then
  516. X        macps $dest_file | lpr $printer
  517. X    else
  518. X        lpr $printer $dest_file
  519. X    endif
  520. X    else # Filter mode; output to stdout, and supress Emacs' messages.
  521. X    emacs -batch $i -l $ctrl_file >/dev/null
  522. X    if ($use_macps != 0) then
  523. X        macps $dest_file
  524. X    else
  525. X        cat $dest_file
  526. X    endif
  527. X    endif
  528. X    /bin/rm -f $dest_file
  529. Xend
  530. X
  531. X# Clean up.
  532. X/bin/rm -f $ctrl_file
  533. Xgoto done
  534. X
  535. X# Give a description of how to invoke this script.
  536. Xusage:
  537. Xecho ""
  538. Xecho "usage: $progname [-P <printer>] [-t] [+|-a] [+|-m] [+|-s] <files>"
  539. Xecho "  If '-t' is present, acts as a filter (writes to standard output)."
  540. Xecho ""
  541. X
  542. Xecho "options ('-' activates, '+' deactivates):"
  543. Xecho "  a: remove Aldus error handler, if present"
  544. Xecho "  m: feed output through macps"
  545. Xecho "  s: strip file, archiving new fonts/ProcSets (active by default)"
  546. X
  547. Xdone:
  548. SHAR_EOF
  549. $TOUCH -am 0725170591 print &&
  550. chmod 0755 print ||
  551. echo "restore of print failed"
  552. set `wc -c print`;Wc_c=$1
  553. if test "$Wc_c" != "5149"; then
  554.     echo original size 5149, current size $Wc_c
  555. fi
  556. # ============= strip-fonts ==============
  557. echo "x - extracting strip-fonts (Text)"
  558. sed 's/^X//' << 'SHAR_EOF' > strip-fonts &&
  559. X#!/bin/csh -f
  560. X#
  561. X# strip-fonts, shell-level command for stripping PostScript fonts from a
  562. X#     Macintosh PostScript document.
  563. X#
  564. X#       This is part of the StripFonts package, (C) 1991 James Elliott
  565. X#       (elliott@cs.wisc.edu).  See the global "Readme" file for
  566. X#       copying information. Requires the GNU Emacs LISP file
  567. X#       stripfonts.el in order to run (and thus, GNU Emacs as well).
  568. X#
  569. X# Use: This script should be run whenever you have uploaded a document
  570. X#       that contains "new" fonts, ie, fonts that are not yet part of
  571. X#       your archived set on this machine. It will copy the fonts into
  572. X#       the archive, so that you will not need to upload them in the
  573. X#       future. By default, it will also save the document with the
  574. X#       fonts stripped out so that it will use less space on disk. If
  575. X#       you are about to print the document, you should just let the
  576. X#       "print" script take care of this for you instead of using this
  577. X#       script; by default "print" strips and saves fonts.
  578. X#
  579. X# Configuration: STRIPFONTS_DIR should be set to the name of the
  580. X#       directory which contains stripfonts.el. If you want the
  581. X#       default behavior to be NOT saving the stripped file, change
  582. X#       the line "set save=1" immediately below to read "set save=0".
  583. X#       Then, unless you specify the "-s" option, stripped versions of
  584. X#       documents will not be saved.
  585. X
  586. X# Get the base name of this shell script. Have to do it this way
  587. X# because a bug in tcsh prevents $0:t from working.
  588. Xset progname=$0
  589. Xset progname=$progname:t
  590. X
  591. X# Set up default behavior.
  592. Xif (! $?STRIPFONTS_DIR) then
  593. X    set STRIPFONTS_DIR = "/var/elisp"
  594. Xendif
  595. Xset files=""
  596. Xset save=1
  597. X
  598. X# Parse command-line arguments.
  599. Xtop:
  600. Xif ($#argv > 0) then
  601. X    switch ($1:q)
  602. X
  603. X    case -s:
  604. X    set save = 1
  605. X    shift
  606. X    goto top
  607. X
  608. X   case +s:
  609. X    set save = 0
  610. X    shift
  611. X    goto top
  612. X
  613. X    case -*:
  614. X    echo "$progname"": unknown option, $1:q"
  615. X    goto usage
  616. X
  617. X    case +*:
  618. X    echo "$progname"": unknown option, $1:q"
  619. X    goto usage
  620. X
  621. X    default:
  622. X    set files = "$files $1:q"
  623. X    shift
  624. X    goto top
  625. X    endsw
  626. Xendif
  627. X
  628. X# If nothing to process, complain.
  629. Xif ("$files" == "") goto usage
  630. X
  631. X# Do what was specified.
  632. Xforeach i ($files)
  633. X    if ($save == 0) then
  634. X        emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-fonts
  635. X    else
  636. X        emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-fonts \
  637. X            -f save-buffer
  638. X    endif
  639. Xend
  640. Xgoto done
  641. X
  642. X# Give a description of how to invoke this script.
  643. Xusage:
  644. Xecho ""
  645. Xecho "usage: $progname [+|-s] <files>"
  646. Xecho ""
  647. X
  648. Xecho "options ('-' activates, '+' deactivates):"
  649. Xecho "  s: save the shortened version of the files (active by default)"
  650. X
  651. Xdone:
  652. SHAR_EOF
  653. $TOUCH -am 0725170791 strip-fonts &&
  654. chmod 0755 strip-fonts ||
  655. echo "restore of strip-fonts failed"
  656. set `wc -c strip-fonts`;Wc_c=$1
  657. if test "$Wc_c" != "2609"; then
  658.     echo original size 2609, current size $Wc_c
  659. fi
  660. # ============= strip-procsets ==============
  661. echo "x - extracting strip-procsets (Text)"
  662. sed 's/^X//' << 'SHAR_EOF' > strip-procsets &&
  663. X#!/bin/csh -f
  664. X#
  665. X# strip-procsets, shell-level command for stripping PostScript ProcSets
  666. X#       from a Macintosh PostScript document.
  667. X#
  668. X#       This is part of the StripFonts package, (C) 1991 James Elliott
  669. X#       (elliott@cs.wisc.edu).  See the global "Readme" file for
  670. X#       copying information. Requires the GNU Emacs LISP file
  671. X#       stripfonts.el in order to run (and thus, GNU Emacs as well).
  672. X#
  673. X# Use: This script should be run whenever you have uploaded a document
  674. X#       that contains "new" ProcSets, ie, ProcSets that are not yet
  675. X#       part of your archived set on this machine. It will copy the
  676. X#       ProcSets into the archive, so that you will not need to upload
  677. X#       them in the future. By default, it will also save the document
  678. X#       with the ProcSets stripped out so that it will use less space
  679. X#       on disk. If you are about to print the document, you should
  680. X#       just let the "print" script take care of this for you instead
  681. X#       of using this script; by default "print" strips and saves
  682. X#       procsets.
  683. X#
  684. X# Configuration: STRIPFONTS_DIR should be set to the name of the
  685. X#       directory which contains stripfonts.el. If you want the
  686. X#       default behavior to be NOT saving the stripped file, change
  687. X#       the line "set save=1" immediately below to read "set save=0".
  688. X#       Then, unless you specify the "-s" option, stripped versions of
  689. X#       documents will not be saved.
  690. X
  691. X# Get the base name of this shell script. Have to do it this way
  692. X# because a bug in tcsh prevents $0:t from working.
  693. Xset progname=$0
  694. Xset progname=$progname:t
  695. X
  696. X# Set up default behavior.
  697. Xif (! $?STRIPFONTS_DIR) then
  698. X    set STRIPFONTS_DIR = "/var/elisp"
  699. Xendif
  700. Xset files=""
  701. Xset save=1
  702. X
  703. X# Parse command-line arguments.
  704. Xtop:
  705. Xif ($#argv > 0) then
  706. X    switch ($1:q)
  707. X
  708. X    case -s:
  709. X    set save = 1
  710. X    shift
  711. X    goto top
  712. X
  713. X   case +s:
  714. X    set save = 0
  715. X    shift
  716. X    goto top
  717. X
  718. X    case -*:
  719. X    echo "$progname"": unknown option, $1:q"
  720. X    goto usage
  721. X
  722. X    case +*:
  723. X    echo "$progname"": unknown option, $1:q"
  724. X    goto usage
  725. X
  726. X    default:
  727. X    set files = "$files $1:q"
  728. X    shift
  729. X    goto top
  730. X    endsw
  731. Xendif
  732. X
  733. X# If nothing to process, complain.
  734. Xif ("$files" == "") goto usage
  735. X
  736. X# Do what was specified.
  737. Xforeach i ($files)
  738. X    if ($save == 0) then
  739. X        emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-procsets
  740. X    else
  741. X        emacs -batch $i -l $STRIPFONTS_DIR/stripfonts -f strip-procsets \
  742. X            -f save-buffer
  743. X    endif
  744. Xend
  745. Xgoto done
  746. X
  747. X# Give a description of how to invoke this script.
  748. Xusage:
  749. Xecho ""
  750. Xecho "usage: $progname [+|-s] <files>"
  751. Xecho ""
  752. X
  753. Xecho "options ('-' activates, '+' deactivates):"
  754. Xecho "  s: save the shortened version of the files (active by default)"
  755. X
  756. Xdone:
  757. SHAR_EOF
  758. $TOUCH -am 0725170991 strip-procsets &&
  759. chmod 0755 strip-procsets ||
  760. echo "restore of strip-procsets failed"
  761. set `wc -c strip-procsets`;Wc_c=$1
  762. if test "$Wc_c" != "2649"; then
  763.     echo original size 2649, current size $Wc_c
  764. fi
  765. # ============= stripfonts.el ==============
  766. echo "x - extracting stripfonts.el (Text)"
  767. sed 's/^X//' << 'SHAR_EOF' > stripfonts.el &&
  768. X;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
  769. X;; stripfonts.el --- UNIX end of StripFonts package.
  770. X;; Author          : James Elliott
  771. X;; Created On      : Sun Sep 9 13:21:59 1990
  772. X;; Last Modified By: James Elliott
  773. X;; Last Modified On: Fri Jun 14 18:17:56 1991
  774. X;; Update Count    : 48
  775. X;; Status          : Author uses frequently; first release to world.
  776. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  777. X
  778. X;;   This is part of the StripFonts package, (C) 1991 James Elliott
  779. X;; (elliott@cs.wisc.edu).  See the global "Readme" file for copying
  780. X;; information.
  781. X;;
  782. X;;   This file defines a set of functions which are useful in working
  783. X;; with Macintosh PostScript files. In conjunction with the Macintosh
  784. X;; end, the package allows font definitions and ProcSets to be omitted
  785. X;; from the files while they are uploaded (and stored on disk) to save
  786. X;; a great deal of time and space. These routines maintain an
  787. X;; organized set of directories which keep copies of the fonts known
  788. X;; so far (so that they need be uploaded only once), strip new fonts
  789. X;; out of documents and into the archives, and re-insert the fonts and
  790. X;; ProcSets into the documents at printing time.
  791. X;;
  792. X;;   You may well wish to use the shell-scripts which were provided
  793. X;; with this file as your primary interface to these functions. Most
  794. X;; day-to-day needs can be filled by the "print" script, which calls
  795. X;; functions in this file by running Emacs in batch mode. If you want
  796. X;; to call the functions yourself, or understand how they work, feel
  797. X;; free to browse through this code.
  798. X
  799. X
  800. X
  801. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  802. X;;
  803. X;; Configuration variables: Edit the values of these variables to
  804. X;; determine where to locate your font archives, etc.
  805. X;;
  806. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  807. X
  808. X(defvar *font-directory* "/var/fonts/"
  809. X  "*Directory in which to find and install copies of the outline
  810. Xfonts used in uploading Macintosh documents.")
  811. X
  812. X(defvar *ps-subdir* "PostScript/"
  813. X  "*Subdirectory name in which PostScript fonts should be placed.")
  814. X
  815. X(defvar *tt-subdir* "TrueType/"
  816. X  "*Subdirectory name in which TrueType fonts should be placed.")
  817. X
  818. X(defvar *unknown-subdir* "unknown/"
  819. X  "*Subdirectory name in which fonts of unknown format (e.g. bitmaps) should
  820. Xbe placed.")
  821. X
  822. X(defvar *procset-subdir* "procsets/"
  823. X  "*Subdirectory name in which ProcSets should be placed.")
  824. X
  825. X(defvar *procset-info* (concat *font-directory* *procset-subdir* "info")
  826. X  "*File containing list of ProcSets and their file names.")
  827. X
  828. X(defvar *screen-files* '("UserPrep" "AdvUserPrep")
  829. X  "List of extraneous files in the fonts directory, such as user prep files,
  830. Xwhich may be desirable in the inclusion process, but should not show up in
  831. Xthe font list.")
  832. X
  833. X
  834. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  835. X;;
  836. X;; Run this function once to create the directories named above. You
  837. X;; need to do this for StripFonts to work properly.
  838. X;;
  839. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  840. X
  841. X(defun setup-directories ()
  842. X  "This function should just be run once when initially setting up your
  843. XStripFonts package; it will create the directories needed by the routines
  844. Xin this file, as specified by the variables above. Configure the variables
  845. Xto your satisfaction before running this."
  846. X
  847. X  (interactive "");
  848. X
  849. X  (shell-command (concat "mkdir "
  850. X             (directory-file-name *font-directory*) " "
  851. X             (directory-file-name (concat *font-directory*
  852. X                              *ps-subdir*)) " "
  853. X             (directory-file-name (concat *font-directory*
  854. X                              *tt-subdir*)) " "
  855. X             (directory-file-name (concat *font-directory*
  856. X                              *unknown-subdir*)) " "
  857. X             (directory-file-name (concat *font-directory*
  858. X                              *procset-subdir*)))))
  859. X
  860. X
  861. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  862. X;;
  863. X;; Here are the functions themselves...
  864. X;;
  865. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  866. X
  867. X(defun strip-fonts ()
  868. X  "Search through a Mac PS document for font definitions and replace them
  869. Xwith include requests. If copies of the fonts are not already present in the
  870. Xfont directory, add them."
  871. X
  872. X  (interactive "")
  873. X
  874. X  (let ((oldbuf (current-buffer))
  875. X    (buf (get-buffer-create "*strip-temp*"))
  876. X    subdir name-prefix
  877. X    name beg)
  878. X
  879. X    (save-excursion
  880. X      (goto-char (point-min))
  881. X      (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
  882. X      (error "File does not seem to be PostScript"))
  883. X      (if (looking-at "%!PS-Adobe")
  884. X      (progn
  885. X        (forward-char 10)
  886. X        (delete-region (point-min) (point))
  887. X        (insert "%!PS-Stripped")))
  888. X      (while (re-search-forward "^%%BeginFont: \\(.*\\)" nil t)
  889. X    (setq name (buffer-substring (match-beginning 1) (match-end 1)))
  890. X    (setq beg (match-beginning 0))
  891. X    (beginning-of-line 2)
  892. X    (if (looking-at "%!PS-AdobeFont-")
  893. X        (setq subdir *ps-subdir* name-prefix "p:")
  894. X      (if (looking-at "%!PS-TrueTypeFont-")
  895. X          (setq subdir *tt-subdir* name-prefix "t:")
  896. X        (setq subdir *unknown-subdir* name-prefix "u:")))
  897. X    (re-search-forward "^%%EndFont *\n")
  898. X    (kill-region beg (match-end 0))
  899. X    (insert (concat "%%#IncludeFont " name-prefix name "\n"))
  900. X    (if (null (file-readable-p (concat *font-directory* subdir name)))
  901. X        (progn
  902. X          (set-buffer buf)
  903. X          (erase-buffer)
  904. X          (yank)
  905. X          (write-file (concat *font-directory* subdir name))
  906. X          (set-buffer oldbuf)
  907. X            )
  908. X        )
  909. X      )
  910. X      (kill-buffer buf)
  911. X)))
  912. X
  913. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  914. X
  915. X(defun procset-filename (name)
  916. X  "Return the name of the file containing the specified ProcSet, if it exists."
  917. X
  918. X  (if (file-exists-p *procset-info*)
  919. X      (let ((oldbuf (current-buffer))
  920. X        (buf (get-buffer-create "*proc-temp*"))
  921. X        (result nil))
  922. X    (set-buffer buf)
  923. X    (erase-buffer)
  924. X    (insert-file *procset-info*)
  925. X    (goto-char (point-min))
  926. X    (if (re-search-forward (concat "^" (regexp-quote name) "\\s-*\t")
  927. X                   nil t)
  928. X        (progn
  929. X          (end-of-line 1)
  930. X          (setq result (buffer-substring (match-end 0) (point)))))
  931. X    (set-buffer oldbuf)
  932. X    (kill-buffer buf)
  933. X    result
  934. X      )
  935. X    nil
  936. X  )
  937. X)
  938. X
  939. X
  940. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  941. X
  942. X
  943. X(defun new-procset-filename (name)
  944. X  "Creates a new file name for the given ProcSet and adds it to the list."
  945. X
  946. X  (let ((oldbuf (current-buffer))
  947. X    (buf (get-buffer-create "*proc-temp*"))
  948. X    (num 1))
  949. X    (set-buffer buf)
  950. X    (erase-buffer)
  951. X    (if (file-exists-p *procset-info*)
  952. X    (insert-file *procset-info*))
  953. X    (goto-char (point-max))
  954. X    (while (file-exists-p (concat *font-directory* *procset-subdir* "set_"
  955. X                  num))
  956. X      (setq num (1+ num)))
  957. X    (insert name "\tset_" (int-to-string num) "\n")
  958. X    (write-file *procset-info*)
  959. X    (set-buffer oldbuf)
  960. X    (kill-buffer buf)
  961. X    (concat "set_" num)
  962. X  )
  963. X)
  964. X
  965. X
  966. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  967. X
  968. X
  969. X(defun strip-procsets ()
  970. X  "Search through a Mac PS document for ProcSets and replace them with
  971. Xinclude requests. If copies of the fonts are not already present in the
  972. Xfont directory, add them."
  973. X
  974. X  (interactive "")
  975. X
  976. X  (let ((oldbuf (current-buffer))
  977. X    (buf (get-buffer-create "*strip-temp*"))
  978. X    name beg)
  979. X
  980. X    (save-excursion
  981. X      (goto-char (point-min))
  982. X      (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
  983. X      (error "File does not seem to be PostScript"))
  984. X      (while (re-search-forward "^%%BeginProcSet: \\(.*\\)" nil t)
  985. X    (setq name (buffer-substring (match-beginning 1) (match-end 1)))
  986. X    (setq beg (match-beginning 0))
  987. X    (re-search-forward "^%%EndProcSet *\n")
  988. X    (kill-region beg (match-end 0))
  989. X    (insert (concat "%%IncludeProcSet " name "\n"))
  990. X    (if (null (procset-filename name))
  991. X        (progn
  992. X          (set-buffer buf)
  993. X          (erase-buffer)
  994. X          (yank)
  995. X          (write-file (concat *font-directory* *procset-subdir*
  996. X                  (new-procset-filename name)))
  997. X          (set-buffer oldbuf)
  998. X            )
  999. X        )
  1000. X      )
  1001. X      (kill-buffer buf)
  1002. X)))
  1003. X
  1004. X
  1005. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1006. X
  1007. X
  1008. X(defun include-fonts ()
  1009. X  "Search through a Mac PS document for font definitions that have been
  1010. Xelided, and replace them with the actual font definitions."
  1011. X
  1012. X  (interactive "")
  1013. X
  1014. X  (let (name name-prefix subdir)
  1015. X    (save-excursion
  1016. X      (goto-char (point-min))
  1017. X      (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
  1018. X      (error "File does not seem to be PostScript"))
  1019. X      (if (looking-at "%!PS-Stripped")
  1020. X      (progn
  1021. X        (forward-char 13)
  1022. X        (delete-region (point-min) (point))
  1023. X        (insert "%!PS-Adobe")))
  1024. X      (while (re-search-forward "^%%#IncludeFont \\(.*\\)\n" nil t)
  1025. X    (setq name (buffer-substring (match-beginning 1) (match-end 1)))
  1026. X    (setq name-prefix (substring name 0 2))
  1027. X    (setq name (substring name 2))
  1028. X    (cond
  1029. X     ((string-equal name-prefix "p:") (setq subdir *ps-subdir*))
  1030. X     ((string-equal name-prefix "t:") (setq subdir *tt-subdir*))
  1031. X     ((string-equal name-prefix "u:") (setq subdir *unknown-subdir*))
  1032. X     (t (setq subdir *ps-subdir*)
  1033. X        (setq name (concat name-prefix name))
  1034. X        (message
  1035. X         "Unknown or missing font prefix for %s; assuming PostScript"
  1036. X         name)))
  1037. X    (if (null (file-readable-p
  1038. X           (concat *font-directory* subdir name)))
  1039. X        (error "Font definition for %s is not available" name))
  1040. X    (kill-region (match-beginning 0) (match-end 0))
  1041. X    (insert-file (concat *font-directory* subdir name))
  1042. X      )
  1043. X    )
  1044. X  )
  1045. X)
  1046. X
  1047. X
  1048. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1049. X
  1050. X
  1051. X(defun include-procsets ()
  1052. X  "Search through a Mac PS document for ProcSets that have been
  1053. Xelided, and replace them with the actual font definitions."
  1054. X
  1055. X  (interactive "")
  1056. X
  1057. X  (save-excursion
  1058. X    (goto-char (point-min))
  1059. X    (if (not (or (looking-at "%!PS-Adobe") (looking-at "%!PS-Stripped")))
  1060. X    (error "File does not seem to be PostScript"))
  1061. X    (while (re-search-forward "^%%IncludeProcSet \\(.*\\)\n" nil t)
  1062. X      (let ((name (buffer-substring (match-beginning 1) (match-end 1)))
  1063. X        (front (match-beginning 0))
  1064. X        (back (match-end 0)))
  1065. X    (if (null (procset-filename name))
  1066. X        (error "ProcSet %s is not available" name))
  1067. X    (kill-region front back)
  1068. X    (insert-file (concat *font-directory* *procset-subdir*
  1069. X                 (procset-filename name)))
  1070. X      )
  1071. X    )
  1072. X  )
  1073. X)
  1074. X
  1075. X
  1076. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1077. X
  1078. X
  1079. X(defun member (item set)  ;; INTERNAL FUNCTION, not for calling by
  1080. X              ;; users.
  1081. X
  1082. X  "Returns NIL if item is not in the list, or the cdr of the list starting
  1083. Xwith that item if it is found."
  1084. X
  1085. X  (while (and set (not (equal (car set) item)))
  1086. X    (setq set (cdr set)))
  1087. X
  1088. X  set
  1089. X)
  1090. X
  1091. X
  1092. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1093. X
  1094. X
  1095. X(defun list-procsets ()
  1096. X  "Insert a list of all the available procsets."
  1097. X
  1098. X  (if (file-exists-p *procset-info*)
  1099. X      (let ((oldbuf (current-buffer))
  1100. X        (buf (get-buffer-create "*proc-temp*"))
  1101. X        name)
  1102. X    (set-buffer buf)
  1103. X    (erase-buffer)
  1104. X    (insert-file *procset-info*)
  1105. X    (goto-char (point-min))
  1106. X    (while (re-search-forward "^\\(.*\\)\t.*$" nil t)
  1107. X      (setq name (buffer-substring (match-beginning 1) (match-end 1)))
  1108. X      (set-buffer oldbuf)
  1109. X      (insert "c:" name "\n")
  1110. X      (set-buffer buf))
  1111. X    (set-buffer oldbuf)
  1112. X    (kill-buffer buf)
  1113. X      )
  1114. X  )
  1115. X)
  1116. X
  1117. X
  1118. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1119. X
  1120. X
  1121. X(defun list-fonts-aux (subdir pfx)  ;; INTERNAL FUNCTION, not for
  1122. X                    ;; calling by users...
  1123. X
  1124. X  "Generate a listing of fonts from SUBDIRECTORY with prefix PREFIX. Used
  1125. Xinternally by list-fonts."
  1126. X
  1127. X  (let ((files (directory-files (concat *font-directory* subdir))))
  1128. X    (while files
  1129. X      (if (and (null (file-directory-p
  1130. X              (concat *font-directory* subdir (car files))))
  1131. X           (not (member (car files) *screen-files*)))
  1132. X      (insert (concat pfx (car files) "\n")))
  1133. X      (setq files (cdr files)))
  1134. X  )
  1135. X)
  1136. X
  1137. X
  1138. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1139. X
  1140. X
  1141. X(defun list-fonts (&optional fname)
  1142. X  "Generate a line for each font file available in the fonts directory.
  1143. XUsed by the Mac end in stripping fonts before uploading. Now also lists
  1144. Xavailable ProcSets. If called with a parameter, saves the list to the
  1145. Xfile named in that parameter (not available interactively)."
  1146. X
  1147. X  (interactive "")
  1148. X
  1149. X  (let ((oldbuf (current-buffer))
  1150. X    (buf (get-buffer-create "*font-list*")))
  1151. X    (set-buffer buf)
  1152. X    (erase-buffer)
  1153. X    (insert "%%StripFonts Format 1.2\n");
  1154. X    (insert "%%List generated on ")
  1155. X    (insert (current-time-string))
  1156. X    (insert "\n");
  1157. X
  1158. X    ;;List the ProcSets which have been uploaded
  1159. X    (insert "\n%%ProcSets available:\n");
  1160. X    (list-procsets)
  1161. X
  1162. X    ;;List the fonts which have been uploaded
  1163. X    (insert "\n%%PostScript fonts available:\n");
  1164. X    (list-fonts-aux *ps-subdir* "p:")
  1165. X    (insert "\n%%TrueType fonts available:\n");
  1166. X    (list-fonts-aux *tt-subdir* "t:")
  1167. X    (insert "\n%%Other fonts available:\n");
  1168. X    (list-fonts-aux *unknown-subdir* "u:")
  1169. X
  1170. X    (goto-char (point-min))
  1171. X    (display-buffer "*font-list*")
  1172. X    (if fname (write-file fname))
  1173. X    (set-buffer oldbuf)
  1174. X  )
  1175. X)
  1176. X
  1177. X
  1178. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1179. X
  1180. X
  1181. X(defun strip-aldus-error-handler ()
  1182. X  "Remove the code from a PS document introduced by Aldus programs to
  1183. Xprint the postscript error on the page. Useful in environments where
  1184. Xthe default error handler is more useful, e.g. it sends mail back to the
  1185. Xperson submitting the job."
  1186. X
  1187. X  (interactive "")
  1188. X
  1189. X  (goto-char (point-min))
  1190. X  (if (re-search-forward
  1191. X       "^%\. Error handling code - don't do this if printing to Lino$" nil t)
  1192. X      (let ((start (match-beginning 0))
  1193. X        (end))
  1194. X    (re-search-forward "^%\.$")
  1195. X    (setq end (match-end 0))
  1196. X    (kill-region start end)
  1197. X    (insert "%% Aldus error handler removed from this spot.")))
  1198. X)
  1199. SHAR_EOF
  1200. $TOUCH -am 0614181791 stripfonts.el &&
  1201. chmod 0644 stripfonts.el ||
  1202. echo "restore of stripfonts.el failed"
  1203. set `wc -c stripfonts.el`;Wc_c=$1
  1204. if test "$Wc_c" != "13838"; then
  1205.     echo original size 13838, current size $Wc_c
  1206. fi
  1207. exit 0
  1208.  
  1209.  
  1210.